package com.wish.g04.financing.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wish.g04.base.entity.CwPayOrder;
import com.wish.g04.base.service.ICwPayOrderService;
import com.wish.g04.financing.dto.PayOrderDTO;
import com.wish.g04.financing.service.PayOrderService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 支付订单表（支付流水信息） 服务实现类
 * </p>
 *
 * @author tyd
 * @since 2022-05-28
 */
@Service
public class PayOrderServiceImpl implements PayOrderService {

    @Autowired
    private ICwPayOrderService iCwPayOrderService;

    /**
     * 查询流水
     * @param cwPayOrderDTO
     * @return
     */
    @Override
    public List<CwPayOrder> getPayOrderList(PayOrderDTO cwPayOrderDTO) {
        QueryWrapper<CwPayOrder> wrapper = new QueryWrapper<>();
        //支付订单号
        if (StringUtils.isNotEmpty(cwPayOrderDTO.getOrderNo())) {
            wrapper.eq("order_no",cwPayOrderDTO.getOrderNo());
        }
        //结算金额
        if (null != cwPayOrderDTO.getFinalAmount()) {
            wrapper.eq("final_amount",cwPayOrderDTO.getFinalAmount());
        }
        //支付金额
        if (null != cwPayOrderDTO.getPayAmount()) {
            wrapper.eq("pay_amount",cwPayOrderDTO.getPayAmount());
        }
        //交易对手
        if (StringUtils.isNotEmpty(cwPayOrderDTO.getTradeUser())) {
            wrapper.eq("trade_user",cwPayOrderDTO.getTradeUser());
        }
        //发起交易日期开始时间
        if (null != cwPayOrderDTO.getTradeDateFq()) {
            wrapper.ge("trade_date_fq",cwPayOrderDTO.getTradeDateFq());
        }
        //发起交易日期结束时间
        if (null != cwPayOrderDTO.getEndTradeDateFq()) {
            wrapper.le("trade_date_fq",cwPayOrderDTO.getEndTradeDateFq());
        }
        //交易账户
        if (StringUtils.isNotEmpty(cwPayOrderDTO.getTradeAccount())) {
            wrapper.eq("trade_account",cwPayOrderDTO.getTradeAccount());
        }
        //对手账号
        if (StringUtils.isNotEmpty(cwPayOrderDTO.getDsAccount())) {
            wrapper.eq("ds_account",cwPayOrderDTO.getDsAccount());
        }
        //支付截止日期开始时间
        if (null != cwPayOrderDTO.getTradeDateJz()) {
            wrapper.ge("trade_date_jz",cwPayOrderDTO.getTradeDateJz());
        }
        //支付截止日期结束时间
        if (null != cwPayOrderDTO.getEndTradeDateFq()) {
            wrapper.le("trade_date_jz",cwPayOrderDTO.getEndTradeDateJz());
        }
        //交易账号
        if (StringUtils.isNotEmpty(cwPayOrderDTO.getTradeAccountNo())) {
            wrapper.eq("trade_account_no",cwPayOrderDTO.getTradeAccountNo());
        }
        //交易渠道
        if (StringUtils.isNotEmpty(cwPayOrderDTO.getTradeQudao())) {
            wrapper.eq("trade_qudao",cwPayOrderDTO.getTradeQudao());
        }
        //交易账户类型
        if (null != cwPayOrderDTO.getTradeAccountType()) {
            wrapper.le("trade_account_type",cwPayOrderDTO.getTradeAccountType());
        }
        //渠道订单号
        if (StringUtils.isNotEmpty(cwPayOrderDTO.getQudaoOrderNo())) {
            wrapper.eq("qudao_order_no",cwPayOrderDTO.getQudaoOrderNo());
        }
        //交易涉及用户类型
        if (null != cwPayOrderDTO.getUserType()) {
            wrapper.le("user_type",cwPayOrderDTO.getUserType());
        }
        //交易结果
        if (null != cwPayOrderDTO.getTradeResult()) {
            wrapper.le("trade_result",cwPayOrderDTO.getTradeResult());
        }
        List<CwPayOrder> cwPayOrderList = iCwPayOrderService.list(wrapper);
        return cwPayOrderList;
    }
}








